var mongoose = require("mongoose");
var Schema = mongoose.Schema;

var users_schema = new Schema({
    username: String,
    password: String,
    age: Number,
    time: Date,
    nickname: String
})

var mvs_schema = new Schema({
    "genres": Array,
    "casts": Array,
    "directors": Array,
    "rating": Object,
    "title": String,
    "collect_count": Number,
    "original_title": String,
    "subtype": String,
    "year": String,
    "images": Object,
    "alt": String,
    "id": String
})


// Model 对象模型  集合对象模型 
// model 是 schema 生成的 模型  可以对数据库的集合进行操作 
//  mongoose.model("集合名称",schemaName)
// 英语复数 
// my ===>  db.mies 
// like ==> db.likes 
// users ==> db.users
// user1 ==> db.user1 
exports.Users = mongoose.model("users", users_schema);

exports.Mvs = mongoose.model("movies", mvs_schema);

var comment_schema = new Schema({
    title: String,
    content: String,
    author: String,
    time: Date,
    mid: String,
    movie: Object,
    answer: Array
})

exports.Comment = mongoose.model("comments", comment_schema);

var prousers1_schema = new Schema({
    mobile: String,
    username: String,
    roomname:String,
    password: String,
    roleid: String,
    time:Date,
    avatar:String
})

exports.Prouser = mongoose.model("prousers1", prousers1_schema);

// 个人体温记录 
var tiwen1_schema = new Schema({
    mobile:String,
    username:String,
    time:Date,
    tiwen:Number,
    ishe:String,  
    is_yin:String  // 1 阴性  0. 阳性  
})

exports.Tiwen = mongoose.model("tiwen1",tiwen1_schema);

// 意见记录 
var advise1_schema = new Schema({
    mobile:String,
    username:String,
    time:Date,
    title:String,
    content:String,
    category:String, // Array 
    reply:Array,
})

exports.Advise = mongoose.model("advise1",advise1_schema);

var good_schema = new Schema({
    "name" : String, 
    "price" :Number, 
    "discount" : Number, 
    "img" : String,
    "type" : Object
})

exports.Goods2 = mongoose.model("goods2",good_schema);

var cart_schema = new Schema({
    "mobile":String,
    good:Object,
    goodId:String,
    count:Number,
    time:Date,
    checked:Boolean
})

exports.Cart = mongoose.model("cart1",cart_schema);

// 查寝填写记录 
var tianxie1_schema = new Schema({
    roomname:String,
    time:Date,
    queqin:Number,
    weisheng:String,  
    yuanyin:String,
    mobile:String  
})

exports.Tianxie = mongoose.model("tianxie1",tianxie1_schema);

var advise2_schema = new Schema({
    mobile:String,
    username:String,
    roomname:String,
    time:Date,
    title:String,
    content:String,
    category:String, // Array 
    reply:Array,
})

exports.Advise2 = mongoose.model("advise2",advise2_schema);